package com.hu.green.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hu.green.entity.Comment;
import com.hu.green.mapper.CommentMapper;
import com.hu.green.service.CommentService;
import com.hu.green.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hu.green.entity.User;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Autowired
    private UserService userService;
    /**
     * 添加用户信息
     * @param comment
     */
    public void addComment(Comment comment){
        User user = userService.getById(comment.getAccount());
        comment.setUrl(user.getImg());
        comment.setName(user.getName());
        this.save(comment);
    }
}
